package avicit.bdp.dgs.metadata.service;

import java.util.List;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author mayi
 */
@Service
public class CatalogDbmsService {

  private final MetadataTableService metadataTableService;

  @Autowired
  public CatalogDbmsService(MetadataTableService metadataTableService) {
    this.metadataTableService = metadataTableService;
  }

  public Boolean removeFromCatalog(List<String> dataAssetIdList) {
    if (CollectionUtils.isNotEmpty(dataAssetIdList)) {
      metadataTableService.batchUpdateCatalogId(null, dataAssetIdList);
      return true;
    }
    return false;
  }

  public Boolean batchAddDataAssetCatalog(String catalogId, List<String> dataAssetIdList) {
    if (CollectionUtils.isNotEmpty(dataAssetIdList)) {
      metadataTableService.batchUpdateCatalogId(catalogId, dataAssetIdList);
      return true;
    }
    return false;
  }
}
